<?php
function outLog($a,$b){
    if($b==0){
        echo "[".time()." $a] success\n";
    }else{
        echo "[".time()." $a] failed\n";
        exit($b);
    }
}
function run($a,$b){
    exec("$a $b",$c,$d);
    outLog($a,$d);
}
if(is_dir("release")){run("rd","/s /q release");}
if(!is_dir("build")){run("md","build");}
run("md","release");
run("md","release\\config");
run("xcopy","src build\\ /E /C /I");
file_put_contents("build/index.php","");
file_put_contents("release/index.php","<?php include(\"phar://core.phar/core/core.php\");");
$phar = new Phar("release/core.phar",0,"index.php");
$phar->buildFromDirectory("build");
$phar->setDefaultStub("index.php","index.php");
run("xcopy","config release\\config");
run("rd","/s /q build");
// run("move","release\\core.phar release\\index.php");
outLog("build",0);